"道长"
import pytest
from until.phone import TestFaker
# from common.read_yaml import ReadYamlConfigs
from common.logintoken import login_ls,login_zs
from api.admin.member_controller_api import MemberControllerApi
from api.admin.receiving_api import ReceivingApi
from common.readconfig import zhangsan_token,lisi_token
# data = ReadYamlConfigs('data.yaml').get_yaml_data()#读取config下的data数据
from common.read_yaml import get_yaml_filepath
from common.readconfig import Environ
data = get_yaml_filepath(Environ=Environ)
"""---------------获取账号数据----------------------"""
@pytest.fixture(scope="session")
def zhangsan_info():
    print("5555:",data["zhangsan"])
    return data["zhangsan"]

@pytest.fixture(scope="session")
def lisi_info():
    print("6666:",data["lisi"])
    return data["lisi"]

"""---------------进行初始化登录---------------------"""
@pytest.fixture(scope="session",autouse=True)
def azs_login(zhangsan_info):
    login_zs(zhangsan_info,"zhangsan_token")

@pytest.fixture(scope="session",autouse=True)
def alisi_login(zhangsan_info):
    login_ls(zhangsan_info,"lisi_token")

"""---------------调用api进行token身份的切换---------------------"""
"""张三角色模块"""
@pytest.fixture(scope="session")
def membercontroller_z():
    return MemberControllerApi(zhangsan_token)

@pytest.fixture(scope="session")
def receiving_z():
    return ReceivingApi(zhangsan_token)

"""李四角色模块"""
@pytest.fixture(scope="session")
def membercontroller_l():
    return MemberControllerApi(lisi_token)

@pytest.fixture(scope="session")
def receiving_l():
    return ReceivingApi(lisi_token)


"""--------------------------------------------------动态传参封装-----------------------------------------------"""
@pytest.fixture(scope="session")
def yzm(membercontroller_l,membercontroller_z):
    """获取验证码"""
    phone = TestFaker().get_phone_number()
    get_auth_code_l = membercontroller_l.get_auth_code(telephone=phone)
    get_auth_code_z = membercontroller_z.get_auth_code(telephone=phone)
    yzm_l = get_auth_code_z['data']
    yzm_z = get_auth_code_z['data']
    return phone,yzm_l,yzm_z
